package com.sheng.view;

import org.apache.poi.ss.usermodel.*;
import org.springframework.web.servlet.view.document.AbstractXlsView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

public class BooksExcel extends AbstractXlsView {

    @Override
    protected void buildExcelDocument(Map<String, Object> model, Workbook workbook, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        Sheet sheet = workbook.createSheet("ContentNegotiate");
        sheet.setDefaultColumnWidth(20);
        Cell cell = sheet.createRow(0).createCell(0);
        cell.setCellValue("五本图书");
        CellStyle cellStyle = workbook.createCellStyle();
        Font font = workbook.createFont();
        font.setColor(Font.COLOR_RED);
        font.setUnderline(Font.U_DOUBLE);
        cellStyle.setFont(font);
        List<String> books = (List<String>) model.get("books");
        for (int i = 0;i<books.size();i++){
            Cell cell1 = sheet.createRow(i + 1).createCell(0);
            cell1.setCellValue(books.get(i));
        }


    }
}
